﻿using BwTMusicModels;
using HwjUIDI.Utility.DatabaseHelper;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BwTMusicServices
{
    public class ModelsHelper
    {
        public North_Music GetNorthMusicModels(SqlDataReader dr)
        {
            North_Music model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new North_Music();
                model.MusicAlbum = database.GetString(dr, "MusicAlbum");
                model.MusicName = database.GetString(dr, "MusicName");
                model.MusicId = database.GetInt(dr, "MusicId");
                model.MusicSinger = database.GetInt(dr, "MusicSinger");
                model.MusicImgUrl = database.GetString(dr, "MusicImgUrl");
                model.MusicCategory = database.GetString(dr, "MusicCategory");
                model.MusicTag = database.GetString(dr, "MusicTag");
                model.MusicClickCount = database.GetInt(dr, "MusicClickCount");
                model.MusicChooseCount = database.GetInt(dr, "MusicChooseCount");
                model.MusicBitRate = database.GetString(dr, "MusicBitRate").Split('?')[database.GetString(dr, "MusicBitRate").Split('?').Length - 1];
                model.MusicTime = database.GetString(dr, "MusicTime");
                model.MusicLong = database.GetString(dr, "MusicLong");
                model.MusicUrl = database.GetString(dr, "MusicUrl");
                model.IsVaild = database.GetString(dr, "IsVaild");
            }
            return model;
        }
        public North_Singer GetNorthSingerModels(SqlDataReader dr)
        {
            North_Singer model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new North_Singer();
                model.SingerAge = database.GetInt(dr, "SingerAge");
                model.SingerName = database.GetString(dr, "SingerName");
                model.SingerId = database.GetInt(dr, "SingerId");
                model.SingerSex = database.GetInt(dr, "SingerSex");
                model.SingerCountry = database.GetString(dr, "SingerCountry");
                model.SingerStyle = database.GetString(dr, "SingerStyle");
                model.SingerBir = database.GetString(dr, "SingerBir");
                model.SingerRank = database.GetInt(dr, "SingerRank");
                model.SingerDesc = database.GetString(dr, "SingerDesc");
                model.SingerPictrue = database.GetString(dr, "SingerPictrue");
            }
            return model;
        }
        public North_Genre GetNorthGenreModels(SqlDataReader dr)
        {
            North_Genre model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new North_Genre();
                model.GenreId = database.GetString(dr, "GenreId");
                model.GenreName = database.GetString(dr, "GenreName");
            }
            return model;
        }
        public North_Country GetNorthCountryModels(SqlDataReader dr)
        {
            North_Country model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new North_Country();
                model.CountryId = database.GetString(dr, "CountryId");
                model.CountryName = database.GetString(dr, "CountryName");
                model.CountryImg = database.GetString(dr, "CountryImg");
            }
            return model;
        }
        public North_Theme GetNorthThemeModels(SqlDataReader dr)
        {
            North_Theme model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new North_Theme();
                model.ThemeId = database.GetString(dr, "ThemeId");
                model.ThemeName = database.GetString(dr, "ThemeName");
            }
            return model;
        }
        public North_Album GetNorthAlbumModels(SqlDataReader dr)
        {
            North_Album model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new North_Album();
                model.AlbumId = database.GetInt(dr, "AlbumId");
                model.AlbumName = database.GetString(dr, "AlbumName");
                model.AlbumPic = database.GetString(dr, "AlbumPic");
                model.AlbumTime = database.GetString(dr, "AlbumTime")!="" ? DateTime.Parse( database.GetString(dr, "AlbumTime")).ToString("yyyy-MM-dd") : "";
                model.AlbumDesc = database.GetString(dr, "AlbumDesc");
            }
            return model;
        }
        public North_Order GetOrderModels(SqlDataReader dr)
        {
            North_Order model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new North_Order();
                model.OrderState = database.GetString(dr, "OrderState");
                model.OrderCustomer = database.GetString(dr, "OrderCustomer");
                model.OrderId = database.GetGuid(dr, "OrderId");
                model.OrderKey = database.GetGuid(dr, "OrderKey");
                model.OrderItem = database.GetString(dr, "OrderItem");
                model.OrderType = database.GetString(dr, "OrderType");
                model.OrderNote = database.GetString(dr, "OrderNote");
                model.OrderTime = database.GetString(dr, "OrderTime");
            }
            return model;
        }
        public SingerAlbum GetSingerAlbumModels(SqlDataReader dr)
        {
            SingerAlbum model = null;
            if (dr == null)
            {
            }
            else
            {
                IDatabase database = DatabaseFactory.GetDatabase();
                model = new SingerAlbum();
                model.AlbumId = database.GetInt(dr, "AlbumId");
                model.SingerAlbumId = database.GetInt(dr, "SingerAlbumId");
                model.SingerId = database.GetInt(dr, "SingerId");
            }
            return model;
        }
     

    }
}
